package com.zjsru.mapper;

import com.zjsru.pojo.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    //根据id查询订单信息
    Order queryOrderById(@Param("order_Id") Long order_Id);

    @Select("select * from tb_order where user_id = #{user_Id}")
    List<Order> queryOrderByUserId(@Param("user_Id") Long user_Id);

    @Insert("insert into tb_order(price,name,num,user_id,product_id) values(#{price},#{name},#{num},#{user_Id},#{product_Id})")
    Order createOrder(Order order);

    @Delete("delete from tb_order where order_id = #{order_Id}")
    void deleteOrder(@Param("order_Id") Long order_Id);

    @Update("update tb_order set status = '已支付' where order_id = #{order_Id}")
    void updateOrderStatus(Long order_Id);

    @Select("select * from tb_order where status = #{status}")
    List<Order> queryOrderByStatus(String status);
}
